<?php
namespace app\admin\controller;
use think\facade\{View,Session,Db};
use app\BaseController;

class User extends Base
{

    public function userlst()
    {
     
        if($this->Ajax){
            $page=input("page",1);
            $size = input("limit", 10);
            $mp=[];
            if(input('type')){
                $mp[]=['vip_expri',input('type')==2 ? ">=" : "<" ,time() ];
            }
            if(input('ish')){
                $mp[]=['is_huser',"=",input('ish')==2 ? 1 : 0 ];
            }
            if (trim(input('reaname'))) {
                $mp[] = ["reaname|nickname", "like", "%" . trim(input('reaname')) . "%"];
            }
            if (trim(input('mobile'))) {
                $mp[] = ["mobile", "like", "%" . trim(input('mobile')) . "%"];
            }
            if(trim(input('tmsg'))){
               
                $eo=[ ["nickname|reaname|mobile", "like","%".trim(input('tmsg'))."%"] ];
                $eo[]=['is_huser',"=",1];
                $hfrIds=Db::name("iuser")->where($eo)->column("id");
                $Ids=$this->getTreamUserCount1($hfrIds);
  
                $mp[]=["id","in",$Ids];
         
            }

            $lst=Db::name("iuser")->where($mp)->order("id desc")->page($page,$size)->select()->toArray();
            foreach($lst as &$v){
                
                $v['addtime']=date("Y-m-d H:i:s",$v['addtime']);
                
            }
            $count= Db::name("iuser")->where($mp)->count();

           

            return resmsg(0,"检索成功",$lst, $count);
        }

        return View::fetch();
    }
   
    public function setUserStatus(){
        $is=Db::name("iuser")->where("id",input("id"))->update(['status'=>input('status')]);
        return $is ? returnmsg(200,"操作成功") : returnmsg(199, "操作异常"); 
    }
 



   
}
